package com.chenxi.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class User implements InitializingBean, BeanNameAware, BeanFactoryAware, ApplicationContextAware {

	public User() {
		System.out.println("1-1、(User)实例化......构造方法......");
	}

	private String userName;

	public void setUserName(String userName) {
		this.userName = userName;
		System.out.println("1-2、(User)属性填充......Setter方法调用......");
	}

	@Override
	public void setBeanName(String beanName) {
		System.out.println("1-3、(User)BeanNameAware......设置BeanName......");
	}


	@Override
	public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
		System.out.println("1-4、(User)BeanFactoryAware......设置beanFactory......");
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		System.out.println("1-5、(User)ApplicationContextAware......设置applicationContext......");
	}

	/**
	 * InitializingBean 接⼝实现
	 */
	@Override
	public void afterPropertiesSet() throws Exception {
		System.out.println("1-6、(User)InitializingBean......afterPropertiesSet方法调用......");
	}

	public void init() {
		System.out.println("1-7、(User)init......init方法......");
	}
}
